package com.jushu.storbox.newfragment;

import android.app.ActionBar.LayoutParams;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Bundle;
import android.os.Message;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
import android.widget.Toast;

import com.jushu.storbox.R;
import com.jushu.storbox.R.string;
import com.jushu.storbox.ShareDriveApplication;
import com.jushu.storbox.TargetFolderBrowserActivity;
import com.jushu.storbox.callback.FileFolderInfoFileSizeSort;
import com.jushu.storbox.callback.FileFolderInfoNameSort;
import com.jushu.storbox.callback.FileFolderInfoTimeSort;
import com.jushu.storbox.constant.ClientConfig;
import com.jushu.storbox.constant.IntentConstant;
import com.jushu.storbox.constant.UiConstant;
import com.jushu.storbox.entities.FileFolderInfo;
import com.jushu.storbox.handler.ClientExceptionRelateHandler;
import com.jushu.storbox.newfragment.argument.FileActionArgs;
import com.jushu.storbox.util.LogUtil;
import com.jushu.storbox.util.PublicTools;
import com.jushu.storbox.view.dialog.PopupMenuWindow;
import com.jushu.storbox.view.resolve.ListDisplayResolve;
import com.jushu.storbox.view.resolve.MyReceveShareDisplayResolve;
import com.jushu.storbox.view.resolve.MySendShareDisplayResolve;
import com.jushu.storbox.view.resolve.OtherPersonShareFilleDisplayResolve;
import com.jushu.storbox.view.viewImpl.StyleView;
import com.jushu.storbox.view.viewImpl.StyleView.OnSelectedListener;
import com.jushu.storbox.vo.PagedList;
import com.huawei.sharedrive.sdk.android.modelV2.response.INodeShareV2;
import com.huawei.sharedrive.sdk.android.modelV2.response.ShareResourceV2;
import com.kennyc.view.MultiStateView;

import java.util.Comparator;

public class ShareFragment extends AbsFrameFragment {
	protected final static String TAG = ShareFragment.class.getSimpleName();
	TitleViewHolder titleHolder = null;

	ShareResourceV2 currentRoot = null;
	StyleView bodyView;
	ListDisplayResolve<?, ?, ?> rootDisplayResolve = null;
	ListDisplayResolve<?, ?, ?> currentDisplayResolve = null;
	MyReceveShareDisplayResolve myRecvShareDisplayResolve;
	MySendShareDisplayResolve mySendShareDisplayResolve;
	OtherPersonShareFilleDisplayResolve shareInnerDataListInfo;
	private MultiStateView multiStateView;

	String currentRootIs = "";
	String rootFolderId = null;
	String rootFolderName = "";
	String openFolderOwner = "";
	FileActionArgs folderArgs = new FileActionArgs();

	@Override
	protected int getTitleResourceId() {
		return R.layout.action_title_style_two;
	}

	@Override
	protected int getContentResourceId() {
		return R.layout.action_body_style_two;
	}

	@Override
	protected void startInitConpentData() {
	}

	@Override
	protected void onLoadTitleView(final View titleView) {
		super.onLoadTitleView(titleView);
		titleHolder = new TitleViewHolder(titleView);
		titleHolder.setTitle(R.string.share_fragment_my_share);
		titleHolder.ic_menu_top_more.setVisibility(View.VISIBLE);
		titleHolder.ic_menu_top_more.setOnClickListener(new OnClickListener() {
			public void onClick(View view) {
				PopupMenuWindow popMenuWindow = new PopupMenuWindow(getActivity(), (int) getActivity().getResources().getDimension(
						R.dimen.item_popup_more_window_width_l), LayoutParams.WRAP_CONTENT, R.layout.adapter_share_view_title_more_item) {
					@Override
					protected void onInflaterFinished(View contentView) {
						View sortShareByRL3 = contentView.findViewById(R.id.adapter_share_view_title_menu_container3);
						View sortShareByRL4 = contentView.findViewById(R.id.adapter_share_view_title_menu_container4);
						View sortShareByRL5 = contentView.findViewById(R.id.adapter_share_view_title_menu_container5);
						View style3 = contentView.findViewById(R.id.style3);
						View style4 = contentView.findViewById(R.id.style4);
						View view3 = contentView.findViewById(R.id.view3);
						View view4 = contentView.findViewById(R.id.view4);
						TextView shareTv3 = (TextView) sortShareByRL3.findViewById(R.id.popmenu_tv_container3);
						TextView shareTv4 = (TextView) sortShareByRL4.findViewById(R.id.popmenu_tv_container4);
						TextView shareTv5 = (TextView) sortShareByRL5.findViewById(R.id.popmenu_tv_container5);
						if (currentDisplayResolve instanceof MyReceveShareDisplayResolve) { // 收到分享的根目录
							shareTv3.setText(string.action_share_by_filename);
							shareTv4.setText(string.action_share_by_shareedtime);
							shareTv5.setText(string.action_share_by_shareedauthor);
							sortShareByRL3.setOnClickListener(new OnClickListener() {
								@Override
								public void onClick(View v) {
									dismiss();
									myRecvShareDisplayResolve.shareSortByFileName(getSortType(UiConstant.SHARE_RECIVE_FILENAME_SORT));
								}
							});

							sortShareByRL4.setOnClickListener(new OnClickListener() {
								@Override
								public void onClick(View v) {
									dismiss();
									myRecvShareDisplayResolve.shareSortByShareTime(getSortType(UiConstant.SHARE_RECIVE_TIME_SORT));
								}
							});

							sortShareByRL5.setOnClickListener(new OnClickListener() {
								public void onClick(View v) {
									dismiss();
									myRecvShareDisplayResolve.shareSortByAuthorName(getSortType(UiConstant.SHARE_RECIVE_AUTHOR_SORT));
								}
							});

						} else if (currentDisplayResolve instanceof MySendShareDisplayResolve) { // 发出分享的根目录
							sortShareByRL4.setVisibility(View.GONE);
							sortShareByRL5.setVisibility(View.GONE);
							view3.setVisibility(View.GONE);
							view4.setVisibility(View.GONE);
							style3.setVisibility(View.GONE);
							style4.setVisibility(View.GONE);// 分割线
							sortShareByRL3.setOnClickListener(new OnClickListener() {
								public void onClick(View v) {
									dismiss();
									mySendShareDisplayResolve.shareSortByFileName(getSortType(UiConstant.SHARE_SEND_FILENAME_SORT));
								}

							});
						} else if (currentDisplayResolve instanceof OtherPersonShareFilleDisplayResolve) {// 在子目录（收到|发送）
							if (currentRootIs.equals(UiConstant.SHARE_RECIVE_SUB_CURRENT_SORT)) {// 收到分享的子目录
								sortShareByRL3.setOnClickListener(new OnClickListener() {
									public void onClick(View v) {
										dismiss();
										shareInnerDataListInfo.shareSubSortByFileName(getSortType(UiConstant.SHARE_RECIVE_SUB_FILENAME_SORT),
												UiConstant.SHARE_RECIVE_SUB_CURRENT_SORT);
									}
								});

								sortShareByRL4.setOnClickListener(new OnClickListener() {
									public void onClick(View v) {
										dismiss();
										shareInnerDataListInfo.shareSubSortByTime(getSortType(UiConstant.SHARE_RECIVE_SUB_TIME_SORT),
												UiConstant.SHARE_RECIVE_SUB_CURRENT_SORT);
									}
								});

								sortShareByRL5.setOnClickListener(new OnClickListener() {
									public void onClick(View v) {
										dismiss();
										shareInnerDataListInfo.shareSubSortBySize(getSortType(UiConstant.SHARE_RECIVE_SUB_SIZE_SORT),
												UiConstant.SHARE_RECIVE_SUB_CURRENT_SORT);
									}
								});
							} else {// 发出分享的子目录
								sortShareByRL3.setOnClickListener(new OnClickListener() {
									public void onClick(View v) {
										dismiss();
										shareInnerDataListInfo.shareSubSortByFileName(getSortType(UiConstant.SHARE_SEND_SUB_FILENAME_SORT),
												UiConstant.SHARE_SEND_SUB_CURRENT_SORT);
									}
								});

								sortShareByRL4.setOnClickListener(new OnClickListener() {
									public void onClick(View v) {
										dismiss();
										shareInnerDataListInfo.shareSubSortByTime(getSortType(UiConstant.SHARE_SEND_SUB_TIME_SORT),
												UiConstant.SHARE_SEND_SUB_CURRENT_SORT);
									}
								});

								sortShareByRL5.setOnClickListener(new OnClickListener() {
									public void onClick(View v) {
										dismiss();
										shareInnerDataListInfo.shareSubSortBySize(getSortType(UiConstant.SHARE_SEND_SUB_SIZE_SORT),
												UiConstant.SHARE_SEND_SUB_CURRENT_SORT);
									}
								});
							}
						} else {
							return;
						}
					}
				};
				int[] location = new int[2];
				view.getLocationOnScreen(location);
				// -5 -- background border is 5dp
				popMenuWindow.showAtLocation(titleView, Gravity.NO_GRAVITY, location[0] - popMenuWindow.getWidth() + view.getWidth(),
						location[1] + view.getHeight() - PublicTools.dipTopx(getActivity(), 5));
			}
		});
	}

	private int getSortType(String type) {
		final int ERROR = -1;
		SharedPreferences preference = getActivity().getSharedPreferences(ClientConfig.settings, Context.MODE_APPEND);
		/* 收到的共享根目录 */
		if (type.equals(UiConstant.SHARE_RECIVE_AUTHOR_SORT))
			return (preference.getInt(UiConstant.SHARE_RECIVE_AUTHOR_SORT, UiConstant.SHARE_RECIVE_SORT_BY_AUTHOR) ^ 0x1000);
		else if (type.equals(UiConstant.SHARE_RECIVE_TIME_SORT))
			return (preference.getInt(UiConstant.SHARE_RECIVE_TIME_SORT, UiConstant.SHARE_RECIVE_SORT_BY_TIME) ^ 0x1000);
		else if (type.equals(UiConstant.SHARE_RECIVE_FILENAME_SORT))
			return (preference.getInt(UiConstant.SHARE_RECIVE_FILENAME_SORT, UiConstant.SHARE_RECIVE_SORT_BY_FILENAME) ^ 0x1000);
		/* 收到共享的子目录 */
		else if (type.equals(UiConstant.SHARE_RECIVE_SUB_FILENAME_SORT))
			return (preference.getInt(UiConstant.SHARE_RECIVE_SUB_FILENAME_SORT, UiConstant.SHARE_RECIVE_SUB_SORT_BY_FILENAME) ^ 0x1000);
		else if (type.equals(UiConstant.SHARE_RECIVE_SUB_SIZE_SORT))
			return (preference.getInt(UiConstant.SHARE_RECIVE_SUB_SIZE_SORT, UiConstant.SHARE_RECIVE_SUB_SORT_BY_SIZE) ^ 0x1000);
		else if (type.equals(UiConstant.SHARE_RECIVE_SUB_TIME_SORT))
			return (preference.getInt(UiConstant.SHARE_RECIVE_SUB_TIME_SORT, UiConstant.SHARE_RECIVE_SUB_SORT_BY_TIME) ^ 0x1000);
		/* 发出的共享根目录 */
		else if (type.equals(UiConstant.SHARE_SEND_FILENAME_SORT))
			return (preference.getInt(UiConstant.SHARE_SEND_FILENAME_SORT, UiConstant.SHARE_SEND_SORT_BY_FILENAME) ^ 0x1000);
		/* 发出共享的子目录 */
		else if (type.equals(UiConstant.SHARE_SEND_SUB_FILENAME_SORT))
			return (preference.getInt(UiConstant.SHARE_SEND_SUB_FILENAME_SORT, UiConstant.SHARE_SEND_SUB_SORT_BY_FILENAME) ^ 0x1000);
		else if (type.equals(UiConstant.SHARE_SEND_SUB_SIZE_SORT))
			return (preference.getInt(UiConstant.SHARE_SEND_SUB_SIZE_SORT, UiConstant.SHARE_SEND_SUB_SORT_BY_SIZE) ^ 0x1000);
		else if (type.equals(UiConstant.SHARE_SEND_SUB_TIME_SORT))
			return (preference.getInt(UiConstant.SHARE_SEND_SUB_TIME_SORT, UiConstant.SHARE_SEND_SUB_SORT_BY_TIME) ^ 0x1000);
		else {
			return ERROR;
		}
	}

	@Override
	protected void onLoadContentView(View contentView) {
		super.onLoadContentView(contentView);
		Log.i("test", "=====================================================");
		multiStateView = (MultiStateView) contentView.findViewById(R.id.multiStateView);
		myRecvShareDisplayResolve = new MyReceveShareDisplayResolve(getActivity(), multiStateView) {
			@Override
			public void onSaveItem(int index, INodeShareV2 info) {
				Intent intent = new Intent(context, TargetFolderBrowserActivity.class);
				Bundle bundle = new Bundle();
				bundle.putInt(IntentConstant.INTENT_SOURCE_RESOURCE_TYPE, info.getType());
				bundle.putString(IntentConstant.INTENT_TARGET_RESOURCE_OWNER, info.getSharedUserId().toString());
				bundle.putString(IntentConstant.INTENT_SOURCE_RESOURCE_ID, info.getNodeId().toString());
				bundle.putString(IntentConstant.INTENT_SOURCE_RESOURCE_OWNER, info.getOwnerId().toString());
				bundle.putInt(IntentConstant.INTENT_COMEFROM_REQUEST, IntentConstant.INTENT_REQUEST_SAVESHARE);//
				intent.putExtra(IntentConstant.INTENT_SEARCH_TARGET_DATA, bundle);
				startActivityForResult(intent, IntentConstant.INTENT_REQUEST_SEARCH_TARGET);
			}

			// switch to FilleDisplayResolve
			@Override
			protected void openFolder(String ownerId, PagedList<FileFolderInfo> pageList) {
				openFolderOwner = ownerId;
				String tempFolderId = pageList.getPagedFolderId();
				String tempFolderName = pageList.getPagedFolderName();
				folderArgs.setFolderId(tempFolderId);
				folderArgs.setFolderName(tempFolderName);
				if (rootFolderId == null) {// open some folder whitch sit at
											// root folder
					rootFolderId = tempFolderId;
					rootFolderName = tempFolderName;
					if (!(currentDisplayResolve instanceof OtherPersonShareFilleDisplayResolve)) {
						currentDisplayResolve = shareInnerDataListInfo;
						currentDisplayResolve.binddingAdapter();
						shareInnerDataListInfo.getAdapter().sort(getMyReciveComparator());
					}
					shareInnerDataListInfo.binddingPagedList(pageList);
					rootDisplayResolve = myRecvShareDisplayResolve;
				}
				titleHolder.showReturnIcon();
				titleHolder.setTitle(rootFolderName);
			}
		};
		mySendShareDisplayResolve = new MySendShareDisplayResolve(getActivity(), multiStateView) {
			// protected void requestActivityForResult(Intent intent) {
			// startActivityForResult(intent,
			// IntentConstant.INTENT_REQUEST_SHARE);
			// }
			@Override
			protected void openFolder(String ownerId, PagedList<FileFolderInfo> pageList) {
				openFolderOwner = ownerId;
				String tempFolderId = pageList.getPagedFolderId();
				String tempFolderName = pageList.getPagedFolderName();
				folderArgs.setFolderId(tempFolderId);
				folderArgs.setFolderName(tempFolderName);
				if (rootFolderId == null) {// open some folder whitch sit at
											// root folder
					rootFolderId = tempFolderId;
					rootFolderName = tempFolderName;
					if (!(currentDisplayResolve instanceof OtherPersonShareFilleDisplayResolve)) {
						currentDisplayResolve = shareInnerDataListInfo;
						currentDisplayResolve.binddingAdapter();
						shareInnerDataListInfo.getAdapter().sort(getMySendComparator());
					}
					shareInnerDataListInfo.binddingPagedList(pageList);
					rootDisplayResolve = mySendShareDisplayResolve;
				}
				titleHolder.showReturnIcon();
				titleHolder.setTitle(rootFolderName);
			}

		};
		shareInnerDataListInfo = new OtherPersonShareFilleDisplayResolve(getActivity(), folderArgs, multiStateView) {
			protected void handleNoMoreParent() {
				currentDisplayResolve = rootDisplayResolve;
				currentDisplayResolve.binddingAdapter();
				rootFolderId = null;
				openFolderOwner = null;
				titleHolder.hideReturnIcon();
				titleHolder.setTitle(R.string.share_fragment_my_share);
			}

			@Override
			protected String aqureOpendResourceOwnerId() {
				return openFolderOwner;
			}

			@Override
			public void onSaveItem(int index, FileFolderInfo info) {
				Intent intent = new Intent(context, TargetFolderBrowserActivity.class);
				Bundle bundle = new Bundle();
				String ownerId = ShareDriveApplication.getInstance().getWnerID();
				bundle.putInt(IntentConstant.INTENT_SOURCE_RESOURCE_TYPE, info.getIsFile());
				bundle.putInt(IntentConstant.INTENT_COMEFROM_REQUEST, IntentConstant.INTENT_REQUEST_SAVESHARE);//
				bundle.putString(IntentConstant.INTENT_TARGET_RESOURCE_OWNER, ownerId);
				bundle.putString(IntentConstant.INTENT_SOURCE_RESOURCE_ID, info.getId().toString());
				bundle.putString(IntentConstant.INTENT_SOURCE_RESOURCE_OWNER, info.getOwnerId());
				intent.putExtra(IntentConstant.INTENT_SEARCH_TARGET_DATA, bundle);
				startActivityForResult(intent, IntentConstant.INTENT_REQUEST_SEARCH_TARGET);
			}

			
			@Override
			protected void updateCurrentFolder(String ownerId, String folderId, String folderName) {
				if (folderId.equals(rootFolderId)) {
					titleHolder.hideReturnIcon();
					titleHolder.setTitle(R.string.share_fragment_my_share);
				} else {
					titleHolder.showReturnIcon();
					titleHolder.setTitle(folderName);
				}
				rootFolderId = folderId;
			}
		};

		bodyView = (StyleView) contentView.findViewById(R.id.translate_compent);
		bodyView.getLeftTextView().setText(R.string.action_share_promit_recvshares);
		bodyView.getRightTextView().setText(R.string.action_share_promit_sendshares);
		bodyView.setOnSelectedListener(onSelectedListener);
		myRecvShareDisplayResolve.initComponent(bodyView.getListView());
		mySendShareDisplayResolve.initComponent(bodyView.getListView());
		shareInnerDataListInfo.initComponent(bodyView.getListView());

		currentDisplayResolve = myRecvShareDisplayResolve;
		currentRootIs = UiConstant.SHARE_RECIVE_SUB_CURRENT_SORT;
		currentDisplayResolve.binddingAdapter();
	}

	private Comparator<FileFolderInfo> getMySendComparator() {
		Comparator<FileFolderInfo> result = null;
		SharedPreferences preference = getActivity().getSharedPreferences(ClientConfig.settings, Context.MODE_APPEND);
		Editor edit = preference.edit();
		int shareSendSubCurrentSort = preference.getInt(UiConstant.SHARE_SEND_SUB_CURRENT_SORT, UiConstant.SHARE_RECIVE_SUB_SORT_BY_FILENAME);
		switch (shareSendSubCurrentSort & 0x000F) {
		case UiConstant.SHARE_SEND_SUB_SORT_BY_FILENAME: // 0X0001
			result = new FileFolderInfoNameSort(shareSendSubCurrentSort);
			break;
		case UiConstant.SHARE_SEND_SUB_SORT_BY_SIZE: // 0X0002
			result = new FileFolderInfoFileSizeSort(shareSendSubCurrentSort);
			break;
		case UiConstant.SHARE_SEND_SUB_SORT_BY_TIME: // 0X0003
			result = new FileFolderInfoTimeSort(shareSendSubCurrentSort);
			break;
		}
		System.out.println("getMySendComparator:" + Integer.toHexString(shareSendSubCurrentSort));
		edit.putInt(UiConstant.SHARE_SEND_SUB_CURRENT_SORT, shareSendSubCurrentSort);
		edit.commit();
		return result;
	};

	private Comparator<FileFolderInfo> getMyReciveComparator() {
		Comparator<FileFolderInfo> result = null;
		SharedPreferences preference = getActivity().getSharedPreferences(ClientConfig.settings, Context.MODE_APPEND);
		Editor edit = preference.edit();
		int shareReciveSubCurrentSort = preference.getInt(UiConstant.SHARE_RECIVE_SUB_CURRENT_SORT, UiConstant.SHARE_RECIVE_SUB_SORT_BY_FILENAME);
		switch (shareReciveSubCurrentSort & 0x000F) {
		case UiConstant.SHARE_RECIVE_SUB_SORT_BY_FILENAME: // 0X0001
			result = new FileFolderInfoNameSort(shareReciveSubCurrentSort);
			break;
		case UiConstant.SHARE_RECIVE_SUB_SORT_BY_SIZE: // 0X0002
			result = new FileFolderInfoFileSizeSort(shareReciveSubCurrentSort);
			break;
		case UiConstant.SHARE_RECIVE_SUB_SORT_BY_TIME: // 0X0003
			result = new FileFolderInfoTimeSort(shareReciveSubCurrentSort);
			break;
		}
		// System.out.println("getMyReciveComparator:" +
		// Integer.toHexString(shareReciveSubCurrentSort) );
		edit.putInt(UiConstant.SHARE_RECIVE_SUB_CURRENT_SORT, shareReciveSubCurrentSort);
		edit.commit();
		return result;
	};

	public void doUpdateCurrentFolder(String ownerId, String folderId, String folderName) {
		if (folderId.equals(rootFolderId)) {
			titleHolder.hideReturnIcon();
			titleHolder.setTitle(R.string.share_fragment_my_share);
		} else {
			titleHolder.showReturnIcon();
			titleHolder.setTitle(folderName);
		}
		rootFolderId = folderId;
	}

	@Override
	public void onActivityResult(int requestCode, int resultCode, Intent intent) {
		switch (requestCode) {
		case IntentConstant.INTENT_REQUEST_SEARCH_TARGET:
			switch (resultCode) {
			case UiConstant.SHARE_ACTION_SAVE_SHARE_RESOURCE: // 共享保存到我的云盘成功
				Toast.makeText(getActivity(), R.string.operate_success, Toast.LENGTH_SHORT).show();
				break;

			case UiConstant.SHARE_ACTION_SAVE_CANCEL: // 共享保存到我的云盘，取消自动重名
//				Toast.makeText(getActivity(), R.string.action_share_save_to_my_cloud_cancel, Toast.LENGTH_SHORT).show();
				break;
			}
			break;
		case IntentConstant.INTENT_REQUEST_SHARE:
			mySendShareDisplayResolve.onActivityResult(resultCode, intent);
			break;
		}
		super.onActivityResult(requestCode, resultCode, intent);
	}

	protected void onBackPressed() {
		LogUtil.e(TAG, "use default backpress listener");
		if (currentDisplayResolve instanceof OtherPersonShareFilleDisplayResolve) {
			shareInnerDataListInfo.openParentFolder();
		}
	}

	protected boolean touchRoot() {
		if (currentDisplayResolve instanceof MySendShareDisplayResolve) {
			return true;
		}

		if (currentDisplayResolve instanceof MyReceveShareDisplayResolve) {
			return true;
		}

		if (shareInnerDataListInfo.getFolderStack().isEmpty()) {
			return true;
		} else {
			return false;
		}
	}

	public OnSelectedListener onSelectedListener = new OnSelectedListener() {
		@Override
		public void onLeftItemSelected(View view) {
			rootFolderId = null;
			openFolderOwner = null;
			titleHolder.hideReturnIcon();
			titleHolder.setTitle(R.string.share_fragment_my_share);
			currentDisplayResolve = myRecvShareDisplayResolve;
			currentRootIs = UiConstant.SHARE_RECIVE_SUB_CURRENT_SORT;
			currentDisplayResolve.binddingAdapter();

		}

		@Override
		public void onRightItemSelected(View view) {
			rootFolderId = null;
			openFolderOwner = null;
			titleHolder.hideReturnIcon();
			titleHolder.setTitle(R.string.share_fragment_my_share);
			currentDisplayResolve = mySendShareDisplayResolve;
			currentRootIs = UiConstant.SHARE_SEND_SUB_CURRENT_SORT;
			currentDisplayResolve.binddingAdapter();

		}
	};

	class TitleViewHolder {
		TextView title;
		View rlReturn;
		View ivReturn;
		View ic_menu_top_more;

		public TitleViewHolder(View titleView) {
			title = (TextView) titleView.findViewById(R.id.file_action_title_folderId);
			ivReturn = titleView.findViewById(R.id.file_action_title_returnIcon);
			ic_menu_top_more = titleView.findViewById(R.id.file_action_title_moreOperation);
			rlReturn = titleView.findViewById(R.id.file_action_title_return_Rl);
			rlReturn.setOnClickListener(new OnClickListener() {
				public void onClick(View arg0) {
					if (currentDisplayResolve instanceof OtherPersonShareFilleDisplayResolve) {
						if (!handleBackPressed()) {
							LogUtil.d(TAG, "no more parent folder!");
						}
					}
				}
			});
		}

		public void hideReturnIcon() {
			ivReturn.setVisibility(View.GONE);
		}

		public void showReturnIcon() {
			ivReturn.setVisibility(View.VISIBLE);
		}

		public void setTitle(int resId) {
			title.setText(resId);
		}

		public void setTitle(String strTitle) {
			title.setText(strTitle);
		}
	}

	ClientExceptionRelateHandler reponseHandler = new ClientExceptionRelateHandler() {

		@Override
		public void handleMessage(Message msg) {
			switch (msg.what) {
			case UiConstant.SHARE_ACTION_SAVE_SHARE_RESOURCE:
				Toast.makeText(getActivity(), R.string.action_transfer_success, Toast.LENGTH_SHORT).show();
				break;

			default:
				super.handleMessage(msg);
			}
		}

		@Override
		public Context getContext() {
			return getActivity();
		}

	};
}